{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "import json\n",
    "from parse_bitstream_v2 import BitstreamParser\n",
    "import hashlib\n",
    "from collections import defaultdict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "import config_command"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "module 'config_command' has no attribute 'asf'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[32], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mconfig_command\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43masf\u001b[49m()\n",
      "\u001b[1;31mAttributeError\u001b[0m: module 'config_command' has no attribute 'asf'"
     ]
    }
   ],
   "source": [
    "\n",
    "config_command.asf()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "json_file_path = r\"E:\\workspace\\parse_bitstream\\parse_bitstream\\压缩位流相关知识\\MCF100T_v2.json\"\n",
    "# 读取JSON文件\n",
    "with open(json_file_path, 'r') as file:\n",
    "    json_file = json.load(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "file_path = r\"E:\\workspace\\parse_bitstream\\parse_bitstream\\压缩位流相关知识\\compress\\原版\\origin.rbt\"\n",
    "bit_parser = BitstreamParser(file_path, \"False\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_frame = bit_parser.rbt_data_content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取特征值\n",
    "# 这里传入content为list， 每个元素的数据类型为 content_type\n",
    "def get_feature(content:list, content_type = \"int\"):\n",
    "    if content_type == \"str\":\n",
    "        # 此时是二进制字符串作为一个元素\n",
    "        combined_string = ''.join(content)\n",
    "        # 使用 hashlib 计算特征值（SHA256）\n",
    "        feature_hash = hashlib.sha256(combined_string.encode()).hexdigest()\n",
    "        return feature_hash\n",
    "    elif content_type == \"int\":\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "32\n",
      "00000000000000000001010000000000\n"
     ]
    }
   ],
   "source": [
    "a = \"00000000000000000001010000000000\"\n",
    "print(len(a))\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "32\n",
      "00000000000000000001000000000000\n"
     ]
    }
   ],
   "source": [
    "b = a[:-11] + '0' + a[-10:]\n",
    "print(len(b))\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "32\n",
      "00000000000000000000010000000000\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3,9,10,11,12]\n",
    "a.append"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "55\n",
      "2\n",
      "2\n",
      "2\n",
      "2\n",
      "6\n",
      "5\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3]\n",
    "b = [4,5,6,2,2,2,2,55]\n",
    "b_len = len(b)\n",
    "for i in range(b_len-1,-1,-1):\n",
    "    print(b[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['1', '1', '0', '1', '1']\n"
     ]
    }
   ],
   "source": [
    "a = \"11011\"\n",
    "# str转list\n",
    "a_list = list(a)\n",
    "print(a_list)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "eda_38",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
